home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJDEV111.ZIP / include / stdio.h < prev    next >
C/C++ Source or Header  |  1993-10-09  |  9KB  |  324 lines

  1. /* This is file stdio.h */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. /* This may look like C code, but it is really -*- C++ -*- */
  8. /* 
  9. Copyright (C) 1988 Free Software Foundation
  10.     written by Doug Lea (dl@rocky.oswego.edu)
  11.  
  12. This file is part of GNU CC.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY.  No author or distributor
  16. accepts responsibility to anyone for the consequences of using it
  17. or for whether it serves any particular purpose or works at all,
  18. unless he says so in writing.  Refer to the GNU CC General Public
  19. License for full details.
  20.  
  21. Everyone is granted permission to copy, modify and redistribute
  22. GNU CC, but only under the conditions described in the
  23. GNU CC General Public License.   A copy of this license is
  24. supposed to have been given to you along with GNU CC so you
  25. can know your rights and responsibilities.  It should be in a
  26. file named COPYING.  Among other things, the copyright notice
  27. and this notice must be preserved on all copies.  
  28. */
  29.  
  30. /*
  31.  *  Please check the following before installing this file:
  32.  *
  33.  *  Make sure USG is #defined if you are on a USG system!
  34.  *
  35.  *  Check the value of _NFILE against the one in your /usr/include/stdio.h.
  36.  *  (USG only)
  37.  *
  38.  *  Check whether your libc.a sprintf function returns
  39.  *  an int (as do most) versus a char* (BSD), and (un)comment
  40.  *  the corresponding SPRINTF_RETURNS_INT line.
  41.  *
  42.  *  Check the value of BUFSIZ against the one in your /usr/include/stdio.h.
  43.  *
  44.  *  Carefully check the fields and order of _iobuf declaration against
  45.  *  the one in your /usr/include/stdio.h. Xenix-based systems
  46.  *  may need some re-ordering of _iobuf. fields.
  47.  *
  48.  *  Note that some _IOXXX #defines may not be present in your 
  49.  *  /usr/include/stdio.h. This is ok, so long as the ones that
  50.  *  are present in both are set to the same values.
  51.  *
  52.  *  Some of the prototypes refer to functions that may not be
  53.  *  present in your libc.a. This is ok so long as you do not
  54.  *  actually call such functions.
  55.  *
  56.  */
  57.  
  58. #ifndef _stdio_h_
  59. #define _stdio_h_
  60.  
  61.  
  62. /*
  63.    HAVE_VPRINTF should be set if vprintf is in libc.a
  64.    HAVE_SETVBUF should be set if setvbuf is in libc.a
  65.    HAVE_SETLINEBUF should be set if setlinebuf in libc.a
  66.  
  67.    The following are probably correct for the listed systems
  68.  
  69. */
  70.  
  71. #ifndef    STDC_HEADERS
  72. #define STDC_HEADERS
  73. #endif
  74.  
  75. #ifdef SYSTEM_FIVE
  76. #define USG
  77. #endif
  78.  
  79. #if defined(USG)
  80. #define  HAVE_VPRINTF
  81. #define  HAVE_SETVBUF  
  82. /* #define  HAVE_SETLINEBUF */
  83.  
  84. #elif defined(vax) || defined(sony)
  85. /* #define HAVE_VPRINTF */
  86. /* #define  HAVE_SETVBUF  */
  87. #define HAVE_SETLINEBUF
  88.  
  89. #elif defined(sun)
  90. #define  HAVE_VPRINTF
  91. #define  HAVE_SETVBUF  
  92. #define  HAVE_SETLINEBUF
  93.  
  94. #elif defined(sequent)
  95. /* #define  HAVE_VPRINTF */
  96. /* #define  HAVE_SETVBUF */
  97. #define  HAVE_SETLINEBUF
  98.  
  99. #elif defined(DGUX)
  100. #define HAVE_VPRINTF
  101. #define HAVE_SETVBUF
  102. #define HAVE_SETLINEBUF
  103. #define IOBUF_FLAG_TYPE int
  104. #define IOBUF_FILE_TYPE int
  105. #define _NFILE 64
  106. #define IOBUF_EXTRA_FIELDS      int _reserve[27];
  107. #define SPRINTF_RETURNS_INT
  108. #define BUFEND_ENTRY_TYPE unsigned char *
  109. #define USG
  110.  
  111. #elif defined(TEKTRONIX_SYSV) || defined(hp9000s300) || defined(i386)
  112. #define  HAVE_VPRINTF
  113. #define  HAVE_SETVBUF
  114. #define HAVE_SETLINEBUF
  115. #define  USG
  116. #undef USG /*DJ*/
  117.  
  118. #elif defined(convex)
  119. /* #define HAVE_VPRINTF */
  120. /* #define HAVE_SETVBUF */
  121. #define HAVE_SETLINEBUF
  122. #define IOBUF_FILE_TYPE unsigned char
  123. #define HAVE_VOID_DOPRNT
  124.  
  125. #endif
  126.  
  127. #ifdef hpux
  128. #define IOBUF_FLAG_TYPE char
  129. #endif
  130.  
  131. #ifdef USG
  132. #define IOBUF_BUFSIZ_FIELD      /* System V ain't got one */
  133. #endif
  134.  
  135. /* Some default definitions for things not defined machine-specifically
  136.    above.  */
  137.  
  138. #ifndef IOBUF_BUFSIZ_FIELD
  139. #define IOBUF_BUFSIZ_FIELD int _bufsiz;
  140. #endif
  141.  
  142. #ifndef IOBUF_FLAG_TYPE
  143. #define IOBUF_FLAG_TYPE short
  144. #endif
  145.  
  146. #ifndef IOBUF_FILE_TYPE
  147. #define IOBUF_FILE_TYPE char
  148. #endif
  149.  
  150. #ifndef IOBUF_EXTRA_FIELDS
  151. #define IOBUF_EXTRA_FIELDS
  152. #endif
  153.  
  154. #if defined(USG) && !defined(_NFILE)
  155. #define _NFILE 20
  156. #endif
  157.  
  158. #ifdef USG
  159. #define _bufend(p) _bufendtab[(p)->_file]
  160. #define _bufsiz(p) (_bufend(p) - (p)->_base)
  161. #ifndef BUFEND_ENTRY_TYPE
  162. #define BUFEND_ENTRY_TYPE char *
  163. #endif
  164. #ifdef __cplusplus
  165. extern "C" {
  166. #endif
  167. BUFEND_ENTRY_TYPE _bufendtab[];
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif
  172.  
  173. /* check this -- hardly any systems need this these days */
  174. #define SPRINTF_RETURNS_INT
  175.  
  176. /* check and possibly redefine the following */
  177. #define BUFSIZ  4096
  178.  
  179. extern  struct  _iobuf {
  180.     int      _cnt;
  181.     char*    _ptr;
  182.     char*    _base;
  183.     IOBUF_BUFSIZ_FIELD
  184.     IOBUF_FLAG_TYPE     _flag;
  185.     IOBUF_FILE_TYPE     _file;
  186.     IOBUF_EXTRA_FIELDS
  187. } _iob[];
  188.  
  189. typedef struct _iobuf FILE;
  190.  
  191. #define _IOFBF    00000
  192. #define _IOREAD   00001
  193. #define _IOWRT    00002
  194. #define _IONBF    00004
  195. #define _IOMYBUF  00010
  196. #define _IOEOF    00020
  197. #define _IOERR    00040
  198. #if defined(USG) && !defined(hpux)
  199. #define _IOSTRG   00000  /* faked out for USG */
  200. #define _IOLBF    00100
  201. #define _IORW     00200
  202. #define _IOAPPEND 00000 /* faked out for USG */
  203. #elif defined(hpux)
  204. #define _IOSTRG   00000  /* faked out for USG */
  205. #define _IOLBF    00200
  206. #define _IORW     00400
  207. #define _IOAPPEND 00000 /* faked out for USG */
  208. #else
  209. #define _IOSTRG   00100
  210. #define _IOLBF    00200
  211. #define _IORW     00400
  212. #define _IOAPPEND 01000
  213. #endif
  214. #ifdef DGUX
  215. #define _IOPBF    00400  /* Boolean - ungetc() not called since fill/flush */
  216. #endif
  217. #define _IOTEXT   02000  /* for MSDOS cr/lf style files */
  218.  
  219. #define EOF       (-1)
  220.  
  221. #ifndef NULL
  222. #define NULL      0
  223. #endif
  224.  
  225. #define stdin     (&_iob[0])
  226. #define stdout    (&_iob[1])
  227. #define stderr    (&_iob[2])
  228. #define stdaux    (&_iob[3])
  229. #define stdprn    (&_iob[4])
  230.  
  231. #define getc(p) (--(p)->_cnt>=0 ? \
  232.   (int)(*(unsigned char*)(p)->_ptr++) : \
  233.   _filbuf(p))
  234. #define putc(x,p) (--(p)->_cnt>=0? \
  235.   ((int)((unsigned char)((*(p)->_ptr++=(unsigned)(x))))): \
  236.   _flsbuf((unsigned)(x),p))
  237.  
  238. #define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
  239. #define getchar()   getc(stdin)
  240. #define putchar(x)  putc(x,stdout)
  241. #define feof(p)     (((p)->_flag&_IOEOF)!=0)
  242. #define ferror(p)   (((p)->_flag&_IOERR)!=0)
  243. #define fileno(p)   ((p)->_file)
  244.  
  245. #ifdef __cplusplus
  246. extern "C" {
  247. #endif
  248.  
  249. int    _doprnt(const char*, void *, FILE*);
  250. int    _doscan(FILE*, const char*, void **argp);
  251. int    _doscan_low(FILE *, int (*)(FILE *), int (*)(int, FILE *),
  252.                    const char *, void **);
  253. int    _filbuf(FILE*);
  254. int    _flsbuf(unsigned, FILE*);
  255. int    fclose(FILE*);
  256. int    fcloseall(void);
  257. FILE*  fdopen(int, const char*);
  258. int    fflush(FILE*);
  259. int    fgetc(FILE*);
  260. char*  fgets(char*, int, FILE *);
  261. FILE*  fopen(const char*, const char*);
  262. int    fprintf(FILE*, const char*, ...);
  263. int    fputc(int, FILE*);
  264. int    fputs(const char*, FILE*);
  265. int    fread(void*, int, int, FILE*);
  266. FILE*  freopen(const char*, const char*, FILE*);
  267. int    fscanf(FILE*, const char*, ...);
  268. int    fseek(FILE*, long, int);
  269. long   ftell(FILE *);
  270. int    fwrite(const void*, int, int, FILE*);
  271. char*  gets(char*);
  272. int    getw(FILE*);
  273. int    pclose(FILE*);
  274. FILE*  popen(const char*, const char*);
  275. int    printf(const char*, ...);
  276. int    puts(const char*);
  277. int    putw(int, FILE*);
  278. void   rewind(FILE*);
  279. int    scanf(const char*, ...);
  280. void   setbuf(FILE*, char*);
  281. void   setbuffer(FILE*, char*, int);
  282. void   setlinebuf(FILE*);
  283. int    setvbuf(FILE*, char*, int, int);
  284. int    sscanf(char*, const char*, ...);
  285. FILE*  tmpfile(void);
  286. int    ungetc(int, FILE*);
  287. int    vfprintf(FILE*, const char*, ...);
  288.  
  289. /* Third arg to vprintf must be '...' for some machines, & does not */
  290. /* hurt for others. */
  291.  
  292. int    vprintf(const char*, ... );
  293.  
  294. #ifdef SPRINTF_RETURNS_INT
  295. int    sprintf(char*, const char*, ...);
  296. int    vsprintf(char*, const char*, ...);
  297. #else
  298. char*  sprintf(char*, const char*, ...);
  299. char*  vsprintf(char*, const char*, ...);
  300. #endif
  301.  
  302. #ifdef __cplusplus
  303. }
  304. #endif
  305.  
  306. #ifndef L_ctermid
  307. #define L_ctermid       9 
  308. #endif
  309. #ifndef L_cuserid
  310. #define L_cuserid       9
  311. #endif
  312. #ifndef P_tmpdir
  313. #define P_tmpdir    "/tmp/"
  314. #endif
  315. #ifndef L_tmpnam
  316. #define L_tmpnam    (sizeof(P_tmpdir) + 15)
  317. #endif
  318.  
  319. #ifndef alloca
  320. #define alloca(x)  __builtin_alloca(x)
  321. #endif
  322.  
  323. #endif /* _stdio_h_ */
  324.